capture log close
cd "C:\Research\Legal Services Corporation\"

log using "robustness_results.txt", text replace

use "acs_small2008.dta", clear
  
foreach year in "09" "10" "11" "12" "13" "14" "15" "16" "17" {
  append using "acs_small20`year'.dta"
}


recode mig (1=0) (2 3=1), gen(moved)

gen rent=ten==3 if ten!=.

gen treat=povpip<125 & rent if povpip!=.

gen clustervar=povpip*10+rent


recode hisp (1=0) (2/24=1), gen(hispanic)
gen racecat=rac1p*10+hispanic

replace eng=0 if eng==.
replace lanx=0 if lanx==.
replace schl=0 if schl==.
replace schg=0 if schg==.
replace dis=0 if dis==.

/* Placebo--non-citizens */

reghdfe move treat if (povpip>=75 & povpip<=175 & cit==5), absorb(rent povpip agep racecat sex mar eng lanx schl schg dis puma st#year) cluster(clustervar)

/* Sensitivity to different bandwidths */

matrix results=J(10,3,.)

local onwhich=1
forvalues i=5(5)50 {
  reghdfe move treat if (povpip>=125-`i' & povpip<=125+`i' & !(cit==5 | mil==1)), absorb(rent povpip agep racecat sex mar eng lanx schl schg dis puma st#year) cluster(clustervar)
  matrix results[`onwhich',1]=_b[treat]
  matrix results[`onwhich',2]=_se[treat]
  matrix results[`onwhich',3]=e(N)
  local onwhich=`onwhich'+1
}



/* Donut RD */

reghdfe move treat if ((povpip>=75 & povpip<=120) | (povpip>=130 & povpip<=175)) & !(cit==5 | mil==1), absorb(rent povpip agep racecat sex mar eng lanx schl schg dis puma st#year) cluster(clustervar)



log close

